package com.google.denta.aspect;

import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

/**
 * Exception Interceptor.
 * @author crash
 */
@Aspect
public class ExceptionAspect {
    /** Logger. */
    private final Logger log = Logger.getLogger(this.getClass());

    /**
     * Simply AfterThrowing.
     * @param ex Throwable aspect system
     */
    @AfterThrowing(pointcut = "execution(* com.google.denta..*.*(..))",
            throwing = "ex")
    public void afterCsThrowing(final Throwable ex) {
        log.error("doAfterThrowing!!! : " + ex.getCause().toString());
    }

    /**
     * Extended AfterThrowing.
     * @param ex Throwable aspect system
     */
    @AfterThrowing(
            pointcut = "execution(* com.google.denta..*Controler.*(..))",
            throwing = "ex")
    public void afterThrowing(final Throwable ex) {
        log.error("doRecoveryActions!!! ", ex);
    }
}
